include ../../Common.mk

include = ../include
user_ld = ../../linker/user.ld 

ULIB = $(shell ls ../lib/*.o)
OBJS = $(shell ls *.c *.S 2>/dev/null | awk '{gsub(/\.c|\.S/, ".o"); print $0}')
PG   = $(addsuffix .out, $(basename $(OBJS)))

.PHONY: clean

%.o: %.S
	$(CC) $(CFLAGS) -I $(include) -c $<

%.o: %.c
	$(CC) $(CFLAGS) -I $(include) -c $<

%.out: %.o $(ULIB)
	$(LD) $(LDFLAGS) -T $(user_ld) -o $@ $^

build: $(PG)
	
clean:
	rm -f *.o *.d *.out